package com.cenntro.auth.utils;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Predicates;

import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author xiegx
 * @version 创建时间：2016-8-16 下午2:01:10
 * SwaggerUI配置
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {  
	
    @Bean
    public Docket createRestApi() {
    	
//    	com.google.common.base.Predicate<RequestHandler> selector1 = RequestHandlerSelectors.basePackage("com.cenntro.auth.controller");
//        com.google.common.base.Predicate<RequestHandler> selector2 = RequestHandlerSelectors.basePackage("com.cenntro.oss.controller");
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //为当前包路径
//                .apis(Predicates.or(selector1,selector2))
                
                .apis(RequestHandlerSelectors.basePackage("com.cenntro"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("运营支撑项目 RESTful APIs")
                .description("后台api接口文档")
                .version("1.0")
                .build();
    }
}